<template>
  <!-- 附表1：2021年度中央企业内部审计工作情况统计表-补充报送项目数 -->
  <j-modal
    :title="'报表审批'"
    :width="800"
    :visible="visible"
    :maskClosable="false"
    :ok-button-props="{ props: { disabled: disableSubmit } }"
    :fullscreen="true"
    @close="close"
    cancelText="关闭"
  >
    <template slot="footer">
      <a-button key="back" style="padding-left: 20px; padding-right: 20px" @click="close()"> 关闭 </a-button>
      <a-popconfirm title="确定不通过吗?" style="width: 150px" @confirm="() => setApproveReason('2')">
        <a-button key="save" style="padding-left: 8px; padding-right: 8px"> 不通过 </a-button>
      </a-popconfirm>
      <a-popconfirm title="确定通过吗?" style="width: 150px" @confirm="() => setApproveReason('3')">
        <a-button key="submit" type="primary"> 通过 </a-button>
      </a-popconfirm>
    </template>
    <a-spin :spinning="Loading">
      <div :class="{ isCheck: isCheck }">
        <!-- <div class="table-header">
          <span class="table-title">填报单位：</span>{{ model.departName }} <span class="table-title">审计负责人：</span
          >{{ model.auditPersonName }} <span class="table-title">填表人：</span>{{ model.createByText }}
          <span class="table-title">填表时间：</span>{{ model.createTime }} <span class="table-title">统计时间：</span
          >{{ model.year }}年（{{ model.quarter }}季度）
        </div> -->
        <a-table
          class="edit-list"
          ref="table"
          size="middle"
          bordered
          width="100vw"
          :pagination="false"
          :columns="columns"
          :dataSource="dataSource"
          :scroll="{ x: 7000 }"
        >
          <div slot="title">
            <div class="title">{{ title }}</div>
            <div class="sub-title">
              <div>填报单位：{{ model.departName }}</div>
              <div>{{ model.year }}年（{{ model.quarter }}季）度</div>
              <div>审计负责人：{{ model.auditPersonName }}</div>
              <div>填表人：{{ model.createByText }}</div>
              <div>填表时间：{{ model.createTime }}</div>
              <div>金额单位（万元）</div>
            </div>
          </div>
          <template slot="customTitle">
            <div class="header-title">企业名称</div>
          </template>
          <template v-slot:a59Title>{{ model.year }}年度内部审计问题已完成整改数（个）</template>
          <template v-slot:a60Title>{{ model.year }}年度内部审计问题整改率（%）</template>
          <template v-slot:a61Title>{{ model.year - 1 }}年度内部审计发现问题整改率（%）</template>
          <template v-for="colrender in customRenderList" v-slot:[colrender]="text, record">
            <j-dict-select-tag
              v-if="colrender == 'a1'"
              :key="colrender"
              class="is-disable-style"
              v-model="record.a1"
              :disabled="disableSubmit"
              style="width: 100%"
              placeholder="请选择集团总部内部审计领导机构类型"
              dict-code="jtzbnbsjldjg_type"
            />
            <j-dict-select-tag
              v-else-if="colrender == 'a2'"
              :key="colrender"
              class="is-disable-style"
              v-model="record.a2"
              :disabled="disableSubmit"
              style="width: 100%"
              placeholder="请选择内部审计工作的领导机构"
              dict-code="sys_yes_or_no"
            />
            <j-dict-select-tag
              v-else-if="colrender == 'a3'"
              :key="colrender"
              class="is-disable-style"
              v-model="record.a3"
              :disabled="disableSubmit"
              style="width: 100%"
              placeholder="请选择集团总部内部审计部门设置"
              dict-code="jtzbnbsjbmjg_type"
            />
            <j-dict-select-tag
              v-else-if="colrender == 'a8'"
              :key="colrender"
              class="is-disable-style"
              v-model="record.a8"
              :disabled="disableSubmit"
              style="width: 100%"
              placeholder="请选择审计信息系统建设应用情况"
              dict-code="sjxxxtjsyyqk_type"
            />
            <a-input
              v-else-if="!disableSubmit &&colrender == 'a0'"
              class="input-title"
              :disabled="disableSubmit"
              v-model="record[colrender]"
              :key="colrender"
              placeholder="请输入企业名称"
            />
            <a-input-number
              v-else-if="!disableSubmit"
              v-model="record[colrender]"
              :disabled="disableSubmit"
              :key="colrender"
              :min="0"
              :max="10000"
            />
            <div :key="colrender" :class="{ 'title-box-scroll': colrender == 'a0' }" v-else>
              {{ record[colrender] }}
            </div>
          </template>
        </a-table>
      </div>
    </a-spin>
    <SetReason ref="setReason" @approveData="approveData"></SetReason>
  </j-modal>
</template>

<script>
import SetReason from '../SetReason'
import { BbspModelMixin } from './BbspModelMixin'
import { httpAction, getAction, postAction } from '@/api/manage'
import columns from './columns10'
export default {
  name: 'ModelView10',
  mixins: [BbspModelMixin],
  components: {
    SetReason,
  },
  data() {
    return {
      columns: columns(),
      dataSource: [],
      model: {},
      type: '1',
      sjType: '8',
      state: '1',
      approveType: '',
      customRenderList: [
        'a0',
        'a1',
        'a2',
        'a3',
        'a4',
        'a5',
        'a6',
        'a7',
        'a8',
        'a9',
        'a10',
        'a12',
        'a15',
        'a17',
        'a19',
        'a20',
        'a11',
        'a13',
        'a14',
        'a16',
        'a18',
        'a21',
        'a22',
        'a23',
        'a24',
        'a25',
        'a26',
        'a27',
        'a28',
        'a29',
        'a30',
        'a31',
        'a32',
        'a33',
        'a34',
        'a35',
        'a36',
        'a37',
        'a38',
        'a39',
        'a40',
        'a41',
        'a42',
        'a43',
        'a44',
        'a45',
        'a46',
        'a47',
        'a48',
        'a49',
        'a50',
        'a51',
        'a52',
        'a53',
        'a54',
        'a55',
        'a56',
        'a57',
        'a58',
        'a59',
        'a60',
        'a61',
      ],
      url: {
        list: '/sjxxzhbb/sjAuditInfo/getGZWOneInfoDetails',
        approve: '/common/sjProcCommon/auditGZWOneApply',
      },
    }
  },
  methods: {
    // 审批
    approve(record) {
      this.Loading = true
      this.model = Object.assign({}, record)
      this.visible = true
      this.getTableData()
    },
    getTableData() {
      getAction(this.url.list, { id: this.model.id }).then((res) => {
        if (res.success && res.result.length > 0) {
          this.model.departName = res.result[0].departName
          this.model.auditPersonName = res.result[0].headName
          this.model.createByText = res.result[0].createByText
          this.model.year = res.result[0].year
          this.model.quarter = res.result[0].quarter
          let data = []
          res.result[0].info.forEach((element) => {
            data = data.concat(JSON.parse(element))
          })
          this.dataSource = data
        } else {
          this.$message.error(res.messgae)
        }
        this.Loading = false
      })
    },
    approveData(data) {
      this.Loading = true
      getAction(this.url.approve, {
        proId: this.model.id,
        state: this.approveType,
        sjType: this.sjType,
        reason: data,
      }).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.Loading = false
          this.visible = false
          this.$emit('ok')
        } else {
          this.$message.error(res.message)
          this.Loading = false
        }
      })
    },
  },
}
</script>

<style lang="less" scoped>
// @import '../../../css/checkAndEdit.less';
@import '../../css/baobiaotable.less';
.input-title {
  height: 30px !important;
}
.table-header {
  margin-bottom: 10px;

  .table-title {
    font-weight: bold;
    margin-left: 15px;
  }
}
.edit-list {
  .header-title {
    height: 140px;
    text-align: center;
    line-height: 140px;
  }
  .is-disable-style {
    /deep/ .ant-select-selection {
      border: 0px;
      background: #fff;
      color: rgba(0, 0, 0, 0.65) !important;
    }
  }
  .title-box-scroll {
    width: 100%;
    height: 45px;
    overflow-x: hidden;
    overflow-y: auto;
  }
}
</style>